export interface ActionElement {
  element: React.ReactNode;
  showActionMenu?: boolean;
  onClick?: (bool: boolean) => void;
}

export const AdvancedButtonWrapperMap = ({ wrapper, setShowActionMenu }: { wrapper?: ActionElement[], setShowActionMenu?(bool: boolean): void }) => {
  if (!wrapper) return null

  return wrapper.map((item, idx) => <ActionElementComponent onClick={setShowActionMenu} showActionMenu={item.showActionMenu} element={item.element} key={idx} />)
}

export const ActionElementComponent: React.FC<ActionElement> = ({ element, onClick, showActionMenu }) => {

  if (!showActionMenu) return element

  return <div onClick={() => {
    onClick && onClick(showActionMenu);
  }} >
    {element}
  </div>;
};

